import redis from 'redis'
import { promisify } from 'util'

import config from '../config'

const client = redis.createClient(config.redis)

client.on('error', (error) => {
  console.error('Redis Connect Error:', error)
  process.exit(1)
})
// bind sync
client.getSync = promisify(client.get).bind(client)
client.setSync = promisify(client.set).bind(client)

client.on('connect', () => {
  console.log('Redis Connect Success')
})
export default client